<template>
  <div ref="modal">
    <vxe-modal
      ref="vmodal"
      v-model="showEdit"
      :title="title"
      :width="modalWidth"
      :height="modalHeight"
      min-width="600"
      min-height="300"
      :loading="submitLoading"
      :show-zoom="true"
      :lock-scroll="true"
      :lock-view="true"
      destroy-on-close>
      <template #default>
        <!--<RoleForm ref="form" :is-modal="title" @modalControl="modalControl"></RoleForm>-->
        <slot name="form"></slot>
      </template>
    </vxe-modal>
  </div>
</template>

<script>
import RoleForm from '@/views/system/RoleManagement/modules/RoleForm'
import { getWindowSize } from '@/utils/util'

export default {
  name: 'RoleModal',
  components: { RoleForm },
  // 监听 数据改变
  watch: {

  },
  props: {
    title: {
      type: [String],
      default: ''
    }
  },
  data () {
    return {
      modalWidth: 'auto',
      modalHeight: 'auto',
      selectRow: null,
      showEdit: false,
      submitLoading: false
    }
  },
  mounted () {
    this.resize()
  },
  methods: {
    resize () {
      const windowSize = getWindowSize()
      console.log(windowSize.windowHeight)
      if (windowSize.windowHeight < 600) {
        this.modalHeight = windowSize.windowHeight * 0.9
      }
    },
    modalControl (val) {
      // console.log(val)
      if (val.submitLoading != null) {
        this.submitLoading = val.submitLoading
      }
      if (val.showEdit != null) {
        this.showEdit = val.showEdit
      }
    }
    // add () {
    //   this.showEdit = true
      // this.$nextTick(() => {
      //   this.$refs.form.add()
      //   this.$refs.form.disabledSubmit = false
      // })
    // },
    // edit (row) {
    //   this.showEdit = true
      // this.$nextTick(() => {
      //   this.$refs.form.edit(row)
      //   this.$refs.form.disabledSubmit = false
      // })
    // },
    // addSub (row) {
    //   this.showEdit = true
    //   this.$nextTick(() => {
    //     this.$refs.form.addSub(row)
    //     this.$refs.form.disabledSubmit = false
    //   })
    // },
    // Detail (row) {
    //   this.showEdit = true
    //   this.$nextTick(() => {
    //     this.$refs.form.Detail(row)
    //     this.$refs.form.disabledSubmit = true
    //   })
    // }
  }
}
</script>

<style lang='less'>

</style>
